package com.itheima.utils;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;

public class SqlSessionUtils {
    private SqlSessionUtils() {
    }

    static SqlSessionFactory build = null;

    static {
        try {
            InputStream is = Resources.getResourceAsStream("SqlMapConfig.xml");
            build = new SqlSessionFactoryBuilder().build(is);

        } catch (IOException e) {
            e.printStackTrace();
        }
    }

        public static  SqlSession getSqlsession(){
         return  build.openSession();
        }



    }

